package org.jivesoftware.smackx.pubsub;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class SubscriptionsExtension extends NodeExtension
{
  protected List<Subscription> items = Collections.EMPTY_LIST;

  public SubscriptionsExtension(String paramString, List<Subscription> paramList)
  {
    super(PubSubElementType.SUBSCRIPTIONS, paramString);
    if (paramList != null)
      this.items = paramList;
  }

  public SubscriptionsExtension(List<Subscription> paramList)
  {
    super(PubSubElementType.SUBSCRIPTIONS);
    if (paramList != null)
      this.items = paramList;
  }

  public List<Subscription> getSubscriptions()
  {
    return this.items;
  }

  public String toXML()
  {
    String str;
    if ((this.items == null) || (this.items.size() == 0))
    {
      str = super.toXML();
      return str;
    }
    StringBuilder localStringBuilder = new StringBuilder("<");
    localStringBuilder.append(getElementName());
    if (getNode() != null)
    {
      localStringBuilder.append(" node='");
      localStringBuilder.append(getNode());
      localStringBuilder.append("'");
    }
    localStringBuilder.append(">");
    Iterator localIterator = this.items.iterator();
    while (true)
    {
      while (!(localIterator.hasNext()))
      {
        localStringBuilder.append("</");
        localStringBuilder.append(getElementName());
        localStringBuilder.append(">");
        str = localStringBuilder.toString();
      }
      localStringBuilder.append(((Subscription)localIterator.next()).toXML());
    }
  }
}